package com.sky.mapper;

import com.sky.entity.Orders;
import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface UserMapper {

    @Select("select * from user where openid=#{openId}")
    User selectByOpenId(String openId);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into user(openid,name,phone,sex,id_number,avatar,create_time)" +
            "value(#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    void insertUser(User user);

    @Select("select * from user where id = #{currentId}")
    User selectById(Long currentId);



    @Select("select count(*) from user where create_time between #{todayStart} and #{todayEnd}")

    Integer selectAll(LocalDateTime todayStart, LocalDateTime todayEnd);

    Integer selectUser(LocalDateTime beginTime, LocalDateTime endTime);
}
